#pragma once

#include "Widgets/ImageWidget.h"
#include "Widgets/Mouse/MouseWidget.h"
#include "CheckBoxWidget.m.h"

RENUM(ExportMacro="WHENGINE_API")
enum class ECheckBoxWidgetState
{
    Checked,
    Unchecked,
    Undetermined, // for multi selection situation 
};

RCLASS()
class WHENGINE_API RCheckBoxWidget : public RImageWidget
{
    ROBJECT
public:
    RCheckBoxWidget();

    ECheckBoxWidgetState GetCheckState();

    //will NOT trigger StateChanged event
    void SetCheckState(ECheckBoxWidgetState InNewState);

    //will NOT trigger StateChanged event
    void SetCheckState(bool InChecked);

    TDelegate<void,ECheckBoxWidgetState /*New State*/ > OnCheckStateChanged;

protected:
    RMouseWidgetPtr Mouse;

    ECheckBoxWidgetState CheckState=ECheckBoxWidgetState::Unchecked;

    bool OnClicked(const SMouseButtonEvent&);

public:
    void SetCheckedImage(RTexture2DPtr InImage);
    void SetUncheckedImage(RTexture2DPtr InImage);
    void SetNotAllCheckedImage(RTexture2DPtr InImage);   
protected:
    RTexture2DPtr Checked;
    RTexture2DPtr Unchecked;
    RTexture2DPtr NotAllChecked;

};